package cn.rui.service;

import cn.rui.common.ContentBean;
import cn.rui.common.ResponseBean;
import cn.rui.mapper.GroupNoticeMapper;
import cn.rui.pojo.GroupNotice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author 徽州大都督
 * @date 2021/6/17
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class GroupNoticeService {

    @Autowired
    private GroupNoticeMapper groupNoticeMapper;

    public ResponseBean queryContent() {
        GroupNotice groupNotice = groupNoticeMapper.selectById (1);
        return ResponseBean.success (ContentBean.QuerySuccess, groupNotice);
    }

    public ResponseBean updateGroupContent(String contents) {
        GroupNotice groupNotice = groupNoticeMapper.selectById (1);
        groupNotice.setContent (contents);
        groupNoticeMapper.updateById (groupNotice);
        return ResponseBean.success (ContentBean.UpdateSuccess);
    }
}
